// internal/domain/snapshot.go
package domain

import (
	"context"
	"time"
)

// SnapshotService 快照服务接口
type SnapshotService interface {
	// 快照管理
	ListSnapshots(ctx context.Context, connID, vmName string) ([]*SnapshotInfo, error)
	GetSnapshot(ctx context.Context, connID, vmName, snapshotName string) (*SnapshotInfo, error)
	CreateSnapshot(ctx context.Context, connID, vmName string, config *SnapshotConfig) (*SnapshotInfo, error)
	DeleteSnapshot(ctx context.Context, connID, vmName, snapshotName string, deleteChildren bool) error

	// 快照操作
	RevertToSnapshot(ctx context.Context, connID, vmName, snapshotName string) error
	GetCurrentSnapshot(ctx context.Context, connID, vmName string) (*SnapshotInfo, error)
}

// SnapshotInfo 快照信息
type SnapshotInfo struct {
	Name        string        `json:"name"`
	Description string        `json:"description"`
	State       SnapshotState `json:"state"`
	Parent      string        `json:"parent,omitempty"`
	Children    []string      `json:"children,omitempty"`
	IsCurrent   bool          `json:"is_current"`
	CreatedAt   time.Time     `json:"created_at"`
	DiskSize    uint64        `json:"disk_size"`
	Memory      bool          `json:"memory"`
}

type SnapshotState string

const (
	SnapshotStateRunning  SnapshotState = "running"
	SnapshotStateShutoff  SnapshotState = "shutoff"
	SnapshotStatePaused   SnapshotState = "paused"
	SnapshotStateDiskOnly SnapshotState = "disk-only"
)

// SnapshotConfig 快照配置
type SnapshotConfig struct {
	Name        string `json:"name" binding:"required"`
	Description string `json:"description"`
	Memory      bool   `json:"memory"`    // 包含内存状态
	Quiesce     bool   `json:"quiesce"`   // 文件系统静默
	Atomic      bool   `json:"atomic"`    // 原子操作
	DiskOnly    bool   `json:"disk_only"` // 仅磁盘快照
}
